import React from 'react';
import { Form, Input, Modal } from 'antd';

export default ({ open, onCancel, onFinish }) => {
  const [form] = Form.useForm();
  // const [checked, setChecked] = useState(false);
  const handleSubmit = async () => {
    form.validateFields().then(async values => {
      onFinish(values);
    });
  };

  const handleCancel = ()=>{
    form.resetFields();
    onCancel();
  }

  return (
    <Modal
      style={{ top: '10%' }}
      width={550}
      title="新建任务"
      open={open}
      onCancel={handleCancel}
      onOk={handleSubmit}
      okText="保存"
    >
      <Form style={{ marginTop: 12 }} form={form}>
        <Form.Item
          label="VIN"
          name="vin"
          rules={[
            {
              required: true,
              message: '请填写VIN',
            },
          ]}
        >
          <Input maxLength={20} placeholder="请输入VIN" />
        </Form.Item>
      </Form>
    </Modal>
  );
};
